package com.erp.warehouse.clouderp_warehouse.exception_handler;

import org.comple.erp.pojo.ResultStatus;
import org.comple.erp.utils.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 2025/10/30 15:46
 * author: 向远洋
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    public static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    // 处理运行时异常
    @ExceptionHandler(RuntimeException.class)
    public AjaxResult exceptionHandle(RuntimeException e) {
        log.error("异常信息为：${}", e.getMessage());
        return AjaxResult.back(ResultStatus.ERROR, "系统异常")
                .add("error", e.getMessage());
    }
}
